package com.gxl.butt.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static com.gxl.butt.value.ErrorMsg.*;
import static com.gxl.butt.value.ErrorMsg.STR_IS_EMPTY;

/**
 * Created by guoxiaolin on 2018/7/24.
 */
public class AccountCheckUtil {

    /** 校验账号**/
    public static boolean checkAccount(String account){
        Pattern pAll1=Pattern.compile(REG_LOWER_LETTER);
        Matcher mAll1 = pAll1.matcher(account);
        if (account==null||STR_IS_EMPTY.equals(account)||!mAll1.matches()){
            return false;
        }
        return true;
    }

    /** 校验密码***/
    public static boolean checkPassword(String password){

        Pattern pAll2=Pattern.compile(REG_MATH);
        Matcher mAll2 = pAll2.matcher(password);
        if (password==null||STR_IS_EMPTY.equals(password)||!mAll2.matches()){
            return false;
        }
        return true;
    }

    /** 校验账号和密码 **/
    public static boolean checkAccountAndPassword(String account,String password){

        Pattern pAll1=Pattern.compile(REG_LOWER_LETTER);
        Matcher mAll1 = pAll1.matcher(account);
        if (account==null||STR_IS_EMPTY.equals(account)||!mAll1.matches()){
            return false;
        }

        Pattern pAll2=Pattern.compile(REG_MATH);
        Matcher mAll2 = pAll2.matcher(password);
        if (password==null||STR_IS_EMPTY.equals(password)||!mAll2.matches()){
            return false;
        }
        return true;
    }
}
